<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入数量">
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
<div></div>
<script>
    //得到文本框和div
    let i = document.querySelector("input");
    let d = document.querySelector("div");
    function f(x) {
        let url = x==1?"a.jpg":"b.jpg";
        //遍历
        for (let j = 0; j < i.value; j++) {
            //创建图片对象
            let img = document.createElement("img");
            img.src = url;
            d.append(img);
        }

    }
</script>
</body>
</html>